﻿using OpenWeb.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.SessionState;

namespace OpenWeb.Site.Controllers
{
    [SessionState(SessionStateBehavior.Disabled)]// sessioni o meno
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Modificare questo modello per avviare l'applicazione ASP.NET MVC.";
           
            //var grid =
            ViewBag.grid = new WebGrid(
                (new List<string>() { "a", "b", "c", "d" }).Select(xx => new { A = xx }).AsQueryable(),
                rowsPerPage:2);
            
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Pagina di descrizione dell'app.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Pagina di contatto.";

            return View();
        }



        public ActionResult SetCulture(string culture)
        {
            // Validate input
            culture = CultureHelper.GetValidCulture(culture);

            // Save culture in a cookie
            HttpCookie cookie = Request.Cookies["_culture"];
            if (cookie != null)
                cookie.Value = culture;   // update cookie value
            else
            {

                cookie = new HttpCookie("_culture");
                cookie.HttpOnly = false; // Not accessible by JS.
                cookie.Value = culture;
                cookie.Expires = DateTime.Now.AddYears(1);
            }
            Response.Cookies.Add(cookie);

            return RedirectToAction("Index");
        }




    }//fC
}
